package me.grm.cs.student;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Objects;

import me.grm.cs.student.IStudent;
import me.grm.cs.student.PostgraduateStudent;
import me.grm.cs.student.UndergraduateStudent;

public class StudentFactory {

    private static final ArrayList<Class<? extends IStudent> > classes = new ArrayList<Class<? extends IStudent> >();
    static {
        classes.add(UndergraduateStudent.class);
        classes.add(PostgraduateStudent.class);
    }
    public static IStudent get(int i) {
        IStudent student = null;
        try {
            student = classes.get(i).getConstructor().newInstance();
        } catch (Exception e) {
            System.out.println(e);
            System.exit(-1);
        }
        return student;
    }
}
